from pyeasyaccept.gui.ChooseScriptsPanel import ChooseScriptsPanel
import unittest
import wx

"""
This class tests the 'ChooseScriptPanel' panel
@author: Danilo Torres
"""
class ChooseScriptsPanelTest(unittest.TestCase):
    
    """
    This method sets initial information
    """
    def setUp(self):
        self.app = wx.App()
        self.frame = wx.Frame(None, -1)
        self.panel = ChooseScriptsPanel(self.frame, -1)
        
        
    """
    This method tear down informations
    """
    def tearDown(self):
        self.app.Destroy()
        self.frame.Destroy()
        self.panel.Destroy()

    """
    This method runs the successful tests
    """
    def testChooseScriptsPanel(self):
        noScript = self.panel.getTestScripts()
        
        test1 = "test1.txt"
        test2 = "test2.txt"
        
        self.panel.idToScriptTest[self.panel.lastScriptTestID - 1].textCtrl.SetValue(test1)
        chooseScript = self.panel.idToScriptTest[self.panel.lastScriptTestID-1]
        chooseScript.checkBox.SetValue(True)

        oneScript = self.panel.getTestScripts()
        
        self.panel.addTestScriptButton.Command(wx.CommandEvent(wx.wxEVT_COMMAND_BUTTON_CLICKED, ChooseScriptsPanel.ADD_SCRIPT_TEST))
        self.panel.idToScriptTest[self.panel.lastScriptTestID - 1].textCtrl.SetValue(test2)
        chooseScript = self.panel.idToScriptTest[self.panel.lastScriptTestID-1]
        chooseScript.checkBox.SetValue(True)
        
        twoScripts = self.panel.getTestScripts()

        self.assertEquals([], noScript)
        self.assertEquals([test1], oneScript)
        self.assertEquals([test1, test2], twoScripts)

    
if __name__ == '__main__':
    unittest.main() 